home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / editor / yg601win.zip / YGREP.H < prev    next >
C/C++ Source or Header  |  1997-03-28  |  7KB  |  240 lines

  1. /*
  2. //    $Id: YGREP.H 1.15 1997/02/11 21:04:42 Y.Roumazeilles Exp $
  3. //
  4. //    (C) 1992-93-94-95-96 Yves Roumazeilles
  5. //
  6. //      Version 6.01
  7. */
  8.  
  9. #ifndef    __YGREP_H__
  10. #define    __YGREP_H__    
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15.  
  16. #ifdef    WINVER
  17. #define    YGCALL    FAR PASCAL
  18. #else
  19. #define    YGCALL    
  20. #endif
  21.  
  22. WORD    YGCALL    YGrepVersion( void );
  23. BOOL    YGCALL    YGrepIsDebug( void );
  24. void    YGCALL    YGrepMessages( BOOL bMessagesAllowed );
  25.  
  26. #define    YO_EOLLF    0x0001L
  27. #define    YO_EOLCR    0x0002L
  28. #define    YO_EOLCRLF    YO_EOLCR|YO_EOLLF
  29. #define    YO_ERRMSG    0x0008L
  30. void    YGCALL    YGrepOptions( long lOptions );
  31.  
  32.  
  33.  
  34.  
  35. /* YGrep Search Engine Error Codes */
  36. #define AGERR_UNKNOWN_TYPE        -1
  37. #define AGERR_NO_ERROR            0
  38. #define AGERR_STATE            1
  39. #define AGERR_ALLOC_MEM            2
  40. #define AGERR_TOO_SHORT            3
  41. #define AGERR_TOO_LONG            4
  42. #define AGERR_NO_PREVIOUS        5
  43. #define AGERR_NO_PATTERN        6
  44.  
  45. #define RGERR_MUNGED_AUTO        20
  46. #define RGERR_MISS_BRACKET        25
  47. #define RGERR_EMPTY_CL            26
  48. #define RGERR_ILLEGAL_CL        27
  49. #define RGERR_TOO_MANY_PAR        28
  50. #define RGERR_NULL_IN_PAR        29
  51. #define RGERR_UNMATCHED            30
  52. #define RGERR_NULL_IN_CRO        31
  53. #define RGERR_CYCLICAL_REF        32
  54. #define RGERR_UNDETERM_REF        33
  55. #define RGERR_UNMATCHED_PAR        34
  56.  
  57. #define    MATCH        0
  58. #define    MISMATCH    1
  59. #define    EXACTMATCH    2
  60. #define    MAXSYM        256    /* Size of the alphabet (in chars) */
  61. #define    WORD_SIZE    512    /* (in bits) */
  62. #define MAXTAG        10
  63.  
  64. #include    "bitlist.h"
  65.  
  66. typedef struct tagAGrepInfo {
  67.     int    iErrorCode;
  68.     char    cPat[WORD_SIZE];
  69.     LPSTR    TagStart[MAXTAG];
  70.     LPSTR    TagEnd[MAXTAG];
  71.     int    bMatchCase;
  72.     int    bMessages;
  73.     BLIST    uMask;        /* internal structures */
  74.     BLIST    uOvMask;
  75.     BLIST    uLimit;
  76.     BLIST    blState;    /* temporary AGrep() structures */
  77.     BLIST    blOverflow;
  78.     BLIST    blTemp;
  79.     BLIST    uTable[MAXSYM];    /* characteristic vector table */
  80.     int    iBitsPerState;
  81.     int    iWordSize;    /* actual word size of BLIST's */
  82.     int    iType;        /* MATCH or MISMATCH */
  83.     char    cUPat[WORD_SIZE];
  84. } AGREPINFO;
  85. #ifdef    WINVER
  86. typedef    AGREPINFO*    PAGREPINFO;
  87. typedef    AGREPINFO FAR*    LPAGREPINFO;
  88. #else
  89. typedef    AGREPINFO*    PAGREPINFO;
  90. typedef    AGREPINFO*    LPAGREPINFO;
  91. #endif
  92.  
  93. int    YGCALL    CompileAGrep( LPCSTR GrepString, int k, BOOL bMatchCase, LPAGREPINFO pGI );
  94. int    YGCALL    AGrep( LPCSTR StringToSearch, LPAGREPINFO pGI );
  95. int    YGCALL    AGrepInit( LPAGREPINFO pGI );
  96. int    YGCALL    AGrepEmpty( LPAGREPINFO pGI );
  97. int    YGCALL    AGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPAGREPINFO pGI );
  98. int    YGCALL    AGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPAGREPINFO pGI );
  99. int    YGCALL    SCompileAGrep( LPCSTR GrepString, int k, BOOL bMatchCase );
  100. int    YGCALL    SAGrep( LPCSTR StringToSearch );
  101. int    YGCALL    SAGrepInit( void );
  102. int    YGCALL    SAGrepEmpty( void );
  103. int    YGCALL    SAGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  104. int    YGCALL    SAGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. #define    MAXDFA    2*WORD_SIZE+32    // It must be double in order to avoid any need for internal error checking
  112.  
  113. typedef struct tagRGrepInfo {
  114.     int    iErrorCode;
  115.     char    cPat[WORD_SIZE];
  116.     LPSTR    TagStart[MAXTAG];
  117.     LPSTR    TagEnd[MAXTAG];
  118.     int    bMatchCase;
  119.     int    bMessages;
  120.     char    cDFA[MAXDFA];        /* internal structures */
  121. } RGREPINFO;
  122. #ifdef    WINVER
  123. typedef    RGREPINFO*    PRGREPINFO;
  124. typedef    RGREPINFO FAR*    LPRGREPINFO;
  125. #else
  126. typedef    RGREPINFO*    PRGREPINFO;
  127. typedef    RGREPINFO*    LPRGREPINFO;
  128. #endif
  129.  
  130. int    YGCALL    CompileRGrep( LPCSTR GrepString, BOOL bMatchCase, LPRGREPINFO pGI );
  131. int    YGCALL    RGrep( LPCSTR StringToSearch, LPRGREPINFO pGI );
  132. int    YGCALL    RGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPRGREPINFO pGI );
  133. int    YGCALL    RGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPRGREPINFO pGI );
  134. void    YGCALL    InitWordCharTable( void );
  135. void    YGCALL    AddWordChar( LPSTR s );
  136. void    YGCALL    RemoveWordChar( LPSTR s );
  137. int    YGCALL    SCompileRGrep( LPCSTR GrepString, BOOL bMatchCase );
  138. int    YGCALL    SRGrep( LPCSTR StringToSearch );
  139. int    YGCALL    SRGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  140. int    YGCALL    SRGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  141.  
  142.  
  143.  
  144.  
  145.  
  146. typedef struct tagSGrepInfo {
  147.     int    iErrorCode;
  148.     char    cPat[WORD_SIZE];
  149.     LPSTR    TagStart[MAXTAG];
  150.     LPSTR    TagEnd[MAXTAG];
  151.     int    bMatchCase;
  152.     int    bMessages;
  153.     char    cDFA[MAXDFA];        /* internal structures */
  154. } SGREPINFO;
  155. #ifdef    WINVER
  156. typedef    SGREPINFO*    PSGREPINFO;
  157. typedef    SGREPINFO FAR*    LPSGREPINFO;
  158. #else
  159. typedef    SGREPINFO*    PSGREPINFO;
  160. typedef    SGREPINFO*    LPSGREPINFO;
  161. #endif
  162.  
  163. int    YGCALL    CompileSGrep( LPCSTR GrepString, BOOL bMatchCase, LPSGREPINFO pGI );
  164. int    YGCALL    SGrep( LPCSTR StringToSearch, LPSGREPINFO pGI );
  165. int    YGCALL    SGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPSGREPINFO pGI );
  166. int    YGCALL    SGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPSGREPINFO pGI );
  167. int    YGCALL    SCompileSGrep( LPCSTR GrepString, BOOL bMatchCase );
  168. int    YGCALL    SSGrep( LPCSTR StringToSearch );
  169. int    YGCALL    SSGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  170. int    YGCALL    SSGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  171.  
  172.  
  173.  
  174.  
  175.  
  176. #define    OP_NOP    0
  177. #define    OP_NOT    1
  178. #define    OP_AND    2
  179. #define    OP_OR    3
  180. #define    OP_NAND    4
  181. #define    OP_NOR    5
  182. #define    OP_ADD    6
  183. #define    OP_SUB    7
  184. #define    OP_UCMP    8
  185. #define    OP_BAND    9
  186. #define    OP_BOR    10
  187. #define    OP_BXOR    11
  188. #define    OP_BNAND    12
  189. #define    OP_BNOR    13
  190.  
  191. typedef    struct tagYGrepInfo {
  192.     union {
  193.         int        opI;    /* One of OP_* values */
  194.         AGREPINFO    aGI;
  195.         RGREPINFO    rGI;
  196.         SGREPINFO    sGI;
  197.     } info;
  198. #ifdef    WINVER
  199.     struct tagYGrepInfo FAR*    pInfo;
  200. #else
  201.     struct tagYGrepInfo *       pInfo;
  202. #endif
  203.     int    iTypeOfInfo;    /* One of IT_* values */
  204. } YGREPINFO;
  205. #ifdef    WINVER
  206. typedef    YGREPINFO*    PYGREPINFO;
  207. typedef    YGREPINFO FAR*    LPYGREPINFO;
  208. #else
  209. typedef    YGREPINFO*    PYGREPINFO;
  210. typedef    YGREPINFO*    LPYGREPINFO;
  211. #endif
  212.  
  213. #define    IT_NONE    -1
  214. #define    IT_OP    0
  215. #define    IT_AG    1
  216. #define    IT_RG    2
  217. #define    IT_SG    3
  218.  
  219. int    YGCALL    PushYInfo( LPYGREPINFO pGI );
  220. int    YGCALL    YGrep( LPCSTR StringToSearch );
  221.  
  222.  
  223.  
  224. void    YGCALL    SFileSetFlags( BOOL bPrintFileName, BOOL bPrintBlockNumber, BOOL bPrintLineNumber, BOOL bCountsOnly, BOOL bNonMatching );
  225. BOOL    YGCALL    SFileOpen( LPCSTR strFileName );
  226. LPSTR    YGCALL    SFileAGrep();
  227. LPSTR    YGCALL    SFileRGrep();
  228. LPSTR    YGCALL    SFileSGrep();
  229. long    YGCALL    SFileClose();
  230.  
  231. int    YGCALL    YGrepGetError();
  232. int    YGCALL    YGrepSetError( int iError );
  233. int    YGCALL    YGrepResetError( int iError );
  234.  
  235.  
  236. #ifdef __cplusplus
  237. } /* extern "C" */
  238. #endif
  239. #endif    /* __YGREP_H__ */
  240.